package com.hospital.register.user.dto;

import com.hospital.register.user.constants.WeixinConstants;
import lombok.Data;

import java.io.Serializable;
import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;

/**
 * 微信扫码登录前，返回给前端的数据
 *
 * @author 刘逸晖
 */
@Data
public class WeixinLoginInfo implements Serializable {

    private String appid;

    private String scope;

    private String redirect_uri;


    private String state;

    /**
     * 无参构造
     * 会初始化所有属性
     * 不可在 WeixinConstants 初始化完成前调用
     *
     * @throws UnsupportedEncodingException
     */
    public WeixinLoginInfo() throws UnsupportedEncodingException {
        this.appid = WeixinConstants.WX_OPEN_APP_ID;
        this.scope = "snsapi_login";
        this.redirect_uri = URLEncoder.encode(WeixinConstants.WX_OPEN_REDIRECT_URL, "utf-8");
        this.state = System.currentTimeMillis() + "";
    }

}
